<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>组件</title>
    <script src="./js/react.development.js"></script>
    <script src="./js/react-dom.development.js"></script>
    <script src="./js/babel.min.js"></script>
    <style>
      header {
        height: 100px;
        background-color: #aef;
      }
  
      main {
        height: 350px;
        background-color: #ceb;
      }
  
      footer {
        height: 100px;
        background-color: #fea;
      }
    </style>
  </head>
  <body>
    <div id="root"></div>
    <script type="text/babel">

      //声明一个类 注意: 名字一定要大写
      class Header extends React.Component{
        // 声明一个方法叫 render (名字不能修改)
        render(){
          return <header></header>;
        }
      }

      class Main extends React.Component{
        render(){
          return <main></main>;
        }
      }

      class Footer extends React.Component{
        render(){
          return <footer></footer>;
        }
      }

      //声明一个类式组件
      class App extends React.Component{
        render(){
            return <div>
              {/* 尝试寻找同名的类, 然后实例化对象, 由『实例化对象』调用 render 方法得到虚拟 DOM 对象   */}
              <Header></Header>
              <Main />
              <Footer />
            </div>
        }
      }

      //渲染     React.createElement(App, null, null);
      ReactDOM.render(<App />, document.querySelector('#root'));
    </script>
  </body>
</html>
